//
//  ESWeatherView.m
//  EasyStyle
//
//  Created by FK on 16/5/4.
//  Copyright © 2016年 FK. All rights reserved.
//

#import "ESWeatherView.h"
#import "ESWeatherNetResult.h"

@interface ESWeatherView ()

@property (weak, nonatomic) IBOutlet UIButton *showWeatherDetailBtn;


@property (weak, nonatomic) IBOutlet UILabel *cityName;
@property (weak, nonatomic) IBOutlet UILabel *weatherInfo;
@property (weak, nonatomic) IBOutlet UIImageView *weatherQualityImg;

@property (weak, nonatomic) IBOutlet UILabel *temperature;

@property (weak, nonatomic) IBOutlet UILabel *curPM;
@property (weak, nonatomic) IBOutlet UIImageView *weatherImg;

;

@end

@implementation ESWeatherView

- (void)awakeFromNib
{
    self.backgroundColor = [UIColor clearColor];
    self.layer.cornerRadius = 5.0;

    
    [_showWeatherDetailBtn addTarget:self action:@selector(showWeatherDetail:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)loadCardWithData:(NSDictionary *)dictResultWeather
{
    ESWeatherNetResult *result = [ESWeatherNetResult new];
    [result getDetailWeatherData:dictResultWeather andDataType:nil];
    
    _cityName.text = result.realtime.cityName;
    _weatherInfo.text = result.realtime.info;
    _temperature.text = [NSString stringWithFormat:@"%@%@",result.realtime.temperature,@"℃"];
    
    _weatherImg.image = [UIImage imageNamed:[weatherInfoImageDict objectForKey:result.realtime.img]];
    _curPM.text = result.PM25.curPm;
    if (result.PM25.curPm.length <= 0) {
        _curPM.text = result.PM25.pm25;
    }
    _weatherQualityImg.image = [UIImage imageNamed:result.PM25.quality];
//    _weatherQuality.text = result.PM25.quality;
}


- (void)showWeatherDetail:(UIButton *)sender
{
    if (_blockShowWeatherDetail) {
        _blockShowWeatherDetail();
    }
}


@end
